#ifndef GPIO2MPD_PIN_H

#define GPIO2MPD_PIN_H

#include <wiringPi.h>
#include <functional>
#include "eventmanager.h"

class Pin;

typedef map<int, Pin*> PinMap;
typedef  map<int,void*> InterruptsMap;

class Pin : public EventManager {
    
    static void _initGPIO();
    static bool _isSetup;
    static const int _validPinsRpiBp[];
    static bool _isPinValid(int pinNum);
    string _getState(); 
    void _updateState(void);
     static bool _pinWatcherFlag;
     static void* _pinWatcherRoutine(void*);
      static PinMap _pinMap;


    protected :
        int number;
        int mode;
        int prevState;
        int state;
        Pin(int, int);

    public:
        void setState(int);
        void printPinState();
        int getState();
        int getPrevState();

        static void initInterruptsMap();

        static Pin* getPin(int);
        static Pin* declarePinUse(int pin, int mode);
        static void startPinWatcher();
        static void stopPinWatcher();
        static int getRotationDirection(Pin*, Pin*);




};


#endif
